package com.gjy.test.other;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.junit.jupiter.api.Test;

import java.util.Base64;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-01-12 10:39:19
 */
public class T6 {

    @Test
    public void test4() {
        String username = "";
        String password = "";
        System.out.println("Basic " + Base64.getUrlEncoder()
                .encodeToString((username + ":" + password).getBytes()));
    }

    @Test
    public void test1() {
        String username = "OA_PIUSER";
        String password = "Abcd1234";
        System.out.println("Basic " + Base64.getUrlEncoder()
                .encodeToString((username + ":" + password).getBytes()));
    }

    @Test
    public void test2() {
        String username = "OA_PP1";
        String password = "beVcWkz8Pa";
        System.out.println("Basic " + Base64.getUrlEncoder()
                .encodeToString((username + ":" + password).getBytes()));
    }

    @Test
    public void test3() {
        JSONObject param = new JSONObject();
        JSONObject head = new JSONObject();
        head.put("INTF_ID", "MM008");
        head.put("SRC_SYSTEM", "OA");
        head.put("SRC_MSGID", "122");
        head.put("DEST_SYSTEM", "SPECD");
        param.put("HEAD", head);

        JSONArray bodyArray = new JSONArray();
        String src = "submit"; // 审批结果
        //R：通过 B：不通过
        String FRGKZ;
        if ("reject".equals(src)) {
            FRGKZ = "B";
        } else {
            FRGKZ = "R";
        }
        int i = 0;
        while (i <= 3) {
            JSONObject item = new JSONObject();
            item.put("EKGRP", "EKGRP");
            item.put("LFDAT", "LFDAT");
            item.put("WERKS", "WERKS");
            item.put("BANFN", "BANFN");
            item.put("MENGE", "MENGE");
            item.put("FRGKZ", FRGKZ); // OA审批结果
            item.put("BNFPO", "BNFPO");
            bodyArray.add(item);
            i++;
        }
        param.put("BODY", bodyArray);

        System.out.println(param);
    }
}
